// 播放
playBtn.onclick = function () {
    if (this.value == '播放') {
        video.play();
        this.value = '暂停';
    } else {
        video.pause();
        this.value = '播放';
    }
}
// 时长
video.ontimeupdate = function () {
    let currentTime = parseInt(video.currentTime); // 获取当前时间
    let duration = parseInt(video.duration); // 获取视频总时长
    // console.log('currentTime', currentTime, 'duration', duration);
    /*
        28:  0:28
        82:  1:22
        123: 2:03
    */
    currentTime = transformTime(currentTime);
    duration = transformTime(duration);
    time.innerText = `${currentTime} / ${duration}`;
}

function transformTime(second) {
    let m = parseInt(second / 60),
        s = parseInt(second % 60);
    if (m < 10) {
        m = '0' + m;
    }
    if (s < 10) {
        s = '0' + s;
    }
    return `${m}:${s}`;
}

// 倍速
speed.onmouseenter = function () {
    speedMenu.style.display = 'block';
}
speed.onmouseleave = function () {
    speedMenu.style.display = 'none';
}
speedMenu.onclick = function (event) {
    video.playbackRate = parseFloat(event.target.innerText);
}